Skip to content

reduce "missing_whitespace_after_keyword" execution time by ~17% #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

abebus
Copy link

@abebus abebus commented Jul 17, 2025

@abebus abebus mentioned this pull request Jul 17, 2025
@abebus abebus changed the title this reduces execution time from ~3300 ns to ~2800 this reduces function execution time by ~17% Jul 17, 2025
@abebus abebus changed the title this reduces function execution time by ~17% reduce "missing_whitespace_after_keyword" execution time by ~17% Jul 17, 2025
@asottile
Copy link
Member

asottile commented Aug 2, 2025

I was able to get another decent improvement by doing something like:

it = iter(tokens)
prev = next(it)
for tok in it:
    ...
    prev = tok

but seems maybe less readable 🤷

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit 024a697 into PyCQA:main Aug 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants